package com.wss.dao;

import com.wss.domain.Account;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 注册dao接口
 */
@Repository
public interface RegisterDao {

    /**
     * 注册帐户 后面的数据变量名应和bean类相同
     * @param account
     * @return
     */
    @Insert("insert into account (username,password,p_id) values (#{username},#{password},#{p_id})")
    int registerAccount(Account account);

    /**
     * 查询该用户名是否已存在
     * @param username
     * @return
     */
    @Select("select count(*) from account where username = #{username}")
    int checkUsername(String username);

    /**
     * 获取刚刚注册的用户
     * @param username
     * @return
     */
    @Select("select * from account where username = #{username}")
    Account getCurrentUser(String username);

}
